package query

import (
	"ssnotify/common/dto"
	"strings"
)

type NotifyConfigGetReq struct {
	dto.Pagination
	dto.OrderBy
	dto.UserInfo
	Name   string `form:"name" search:"type:contains;column:name;table:sys_notify_config"`
	DeptId string `form:"deptId" search:"-"`
	Id     string `form:"id" search:"type:exact;column:id;table:sys_notify_config"`

	Source     string   `search:"type:exact;column:source;table:sys_notify_config"`
	Status     string   `search:"type:exact;column:status;table:sys_notify_config"`
	Type       string   `search:"type:exact;column:type;table:sys_notify_config"`
	DeptIdEq   string   `search:"type:exact;column:dept_id;table:sys_notify_config"`
	DeptIdIn   []string `search:"type:in;column:dept_id;table:sys_notify_config"`
	IdIn       []string `search:"type:in;column:id;table:sys_notify_config"`
	AgencyIdEq string   `search:"type:exact;column:agency_id;table:sys_notify_config"`
}

func (m *NotifyConfigGetReq) GetNeedSearch() interface{} {
	if len(m.DeptId) > 0 {
		m.DeptIdIn = strings.Split(strings.ReplaceAll(m.DeptId, " ", ""), ",")
	}
	if m.UserId != "1" {
		m.AgencyIdEq = m.AgencyId
	}
	return *m
}
